﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WineModel;
using System.Data;
using System.Web.Script.Serialization;
using System.Collections;
using System.Data.SqlClient;

namespace WineDAL
{
   public  class WineCikkectDAL
    {
        SQLHelper helper = new SQLHelper();
       /// <summary>
       /// 收藏显示商品信息
       /// </summary>
       /// <returns></returns>
        public ArrayList CikkectShow(int id)
        {
            SqlParameter par = new SqlParameter("@id", id);
            DataTable table = helper.ExecDataTable_Proc("Cikkect_Show",par);
            JavaScriptSerializer jss = new JavaScriptSerializer();
            System.Collections.ArrayList dic = new System.Collections.ArrayList();
            foreach (DataRow dr in table.Rows)
            {
                System.Collections.Generic.Dictionary<string, object> drow = new System.Collections.Generic.Dictionary<string, object>();
                foreach (DataColumn dc in table.Columns)
                {
                    drow.Add(dc.ColumnName, dr[dc.ColumnName]);
                }
                dic.Add(drow);
            }
            return dic;
        }


        /// <summary>
        /// 添加收藏
        /// </summary>
        /// <param name="shop"></param>
        /// <returns></returns>
        public int CikkectAdd(WineModel.Cikkect cc)
        {
            SqlParameter[] par = { new SqlParameter("@GoodsID", cc.GoodsID), new SqlParameter("@UsersID", cc.UsersID), new SqlParameter("@CokkectDate", cc.CollectionTime) };
            return helper.ExecNonquery_Proc("Cikkect_Add", par);
        }

       /// <summary>
       /// 取消收藏
       /// </summary>
       /// <param name="id"></param>
       /// <returns></returns>
        public int CikkectDelete(int id)
        {
            SqlParameter[] pare = new SqlParameter[]{
            new SqlParameter("@id",id)
           };
            return helper.ExecNonquery_Proc("Cikkect_Delete", pare);
        }
        
    }
}
